package com.fare.taluo.fetl.domain.entity;

import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.dayatang.domain.InstanceFactory;
import com.fare.taluo.fetl.domain.base.BaseFetlEntity;
import com.fare.taluo.fetl.domain.repository.IFreightMonitorCabinRepository;
import com.fare.taluo.fetl.domain.repository.IFreightMontorRepository;

@Entity
@Table(name="freight_monitor_cabins")
public class FreightMonitorCabinsEntity extends BaseFetlEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1673986477370395697L;
	@Id
	@Column(name="ID", length=32)
	@GeneratedValue(strategy = GenerationType.AUTO)
	private String id;
	
	@Column(name="cabinName")
	private String cabinName;
	
	@Column(name="price")
	private String price;
	
	@Column(name="productName")
	private String productName;
	
	@Column(name="level")
	private int level;
	
	@Column(name="cabinType")
	private String cabinType;
	
	@Column(name="monitorId")
	private String monitorId;
    
	/*@ManyToOne(cascade = CascadeType.ALL, optional = false)
	//@JoinColumn(name="id", referencedColumnName="id")
	@JoinColumn(name="id", referencedColumnName="id")
	private FreightMontiorEntity freightMontiorEntity ;*/
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCabinName() {
		return cabinName;
	}

	public void setCabinName(String cabinName) {
		this.cabinName = cabinName;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public String getCabinType() {
		return cabinType;
	}

	public void setCabinType(String cabinType) {
		this.cabinType = cabinType;
	}

	public String getMonitorId() {
		return monitorId;
	}

	public void setMonitorId(String monitorId) {
		this.monitorId = monitorId;
	}
	
/*	public FreightMontiorEntity getFreightMontiorEntity() {
		return freightMontiorEntity;
	}

	public void setFreightMontiorEntity(FreightMontiorEntity freightMontiorEntity) {
		this.freightMontiorEntity = freightMontiorEntity;
	}*/
	private static IFreightMonitorCabinRepository getIFreightMonitorCabinRepository(){
		return InstanceFactory.getInstance(IFreightMonitorCabinRepository.class);
	}
	//private static IFreightMonitorCabinRepository freightMontorCabinRepository = InstanceFactory.getInstance(IFreightMonitorCabinRepository.class);
	
	

	public List<FreightMonitorCabinsEntity> findCabinEntityByFreightMonitor(String id){
		return getIFreightMonitorCabinRepository().findCabinEntityByFreightMonitor(id);
	}
	
	
	@Override
	public boolean isNew() {
		return getId() == null ;
	}

	@Override
	public boolean existed() {
		if (isNew()) {
			return false;
		}
		return getBaseEntityRepository().exists(getClass(), getId());
	}

	@Override
	public boolean notExisted() {
		return ! existed();
	}
	
	@Override
	public boolean existed(String propertyName, Object propertyValue) {
		// TODO Auto-generated method stub
		return false;
	}

}
